/******************* (C) COPYRIGHT 2022 CHU WEI TENG ***********************************************
**
**------------------ File Info ---------------------------------------------------------------------
** File name:      dwin_fifo.h
** modified Date:  2022-05-10
** Last Version:   V1.0
** Descriptions: 
** 
**------------------ Modfication  log --------------------------------------------------------------
** Date       Who            Rev        Comments
----------------------------------------------------------------------------------------------------
   22/05/10  chuwt@qq.com    V1.00      created

****************************************************************************************************/
#ifndef __DWIN_FIFO_H__
#define __DWIN_FIFO_H__

#include "dwin_types_def.h"

/* Public define-----------------------------------------------------------------------------------*/

/* Public typedef----------------------------------------------------------------------------------*/
typedef struct 
{
    void*      elem_ptr;
    uint32_t   elem_size; 
    uint32_t   capacity;
    uint32_t   out;
    uint32_t   in;
    uint32_t   mask;
}dwin_fifo_t;

/* Public function---------------------------------------------------------------------------------*/

dwin_fifo_t* dwin_fifo_create(uint32_t elem_size, uint32_t capacity);
ret_t dwin_fifo_destory(dwin_fifo_t* fifo);

uint32_t dwin_fifo_push(dwin_fifo_t* fifo, void* data);
uint32_t dwin_fifo_pop(dwin_fifo_t* fifo, void* data);
uint32_t dwin_fifo_peek(dwin_fifo_t* fifo, void* data);
uint32_t dwin_fifo_mutli_push(dwin_fifo_t* fifo, void* data, uint32_t elem_cnt);
uint32_t dwin_fifo_mutli_pop(dwin_fifo_t* fifo, void* data, uint32_t elem_cnt);
uint32_t dwin_fifo_mutli_peek(dwin_fifo_t* fifo, void* data, uint32_t elem_cnt);

uint32_t dwin_fifo_get_count(dwin_fifo_t* fifo);
ret_t dwin_fifo_clear(dwin_fifo_t* fifo);
uint8_t dwin_fifo_is_empty(dwin_fifo_t* fifo);
uint8_t dwin_fifo_is_full(dwin_fifo_t* fifo);

#endif
